const Mock = require('mockjs')

const data = Mock.mock({
  'items|10': [{
    id: '@id',
    title: '@sentence(5, 10)',
    'status|1': ['published', 'draft', 'deleted'],
    author: 'name',
    display_time: '@datetime',
    pageviews: '@integer(300, 5000)'
  }]
})

const users = Mock.mock({
  'items|10': [{
    id: '@id',
    name: '@sentence(1, 3)',
    'age|1': ['男', '女'],
    address: '@county(true)',
  }]
})

module.exports = [
  {
    url: '/vue-admin-template/user/list',
    type: 'get',
    response: config => {
      const items = users.items
      return {
        code: 20000,
        data: {
          total: items.length,
          items: items
        }
      }
    }
  }, 
  {
    url: '/vue-admin-template/table/list',
    type: 'get',
    response: config => {
      const items = data.items
      return {
        code: 20000,
        data: {
          total: items.length,
          items: items
        }
      }
    }
  }, {
    url: '/vue-admin-template/table/del',
    type: 'delete',
    response: config => {
      return {
        code: 20000,
        data: 'success'
      }
    }
  }, {
    url: '/vue-admin-template/table/get',
    type: 'get',
    response: config => {
      return {
        code: 20000,
        data: {
          id: '@id',
          title: '@sentence(5, 10)',
          'status|1': ['published', 'draft', 'deleted'],
          author: 'name',
          display_time: '@datetime',
          pageviews: '@integer(300, 5000)'
        }
      }
    }
  }, {
    url: '/vue-admin-template/table/edit',
    type: 'put',
    response: config => {
      return {
        code: 20000,
        data: 'success'
      }
    }
  }, {
    url: '/vue-admin-template/table/add',
    type: 'post',
    response: config => {
      return {
        code: 20000,
        data: 'success'
      }
    }
  }
]
